<template>

  <div class="coupon_out" ref="homePage">
    <div class="coupon">
      <div class="coupon_title">
        <ul class="tabTit">
          <li v-for="(item,index) in tabs" :class="{active:index == num}" @click="tab(index)">{{item}}</li>
        </ul>      
      </div>

      <div class="tabCon">
        <ul>
          <li class="list list1" v-for="(itemCon,index) in tabContent0" v-show="0 == num" v-if="itemCon.status == 0">
            <div class="list_part list_part1 flex">
              <p class="list_name" v-if="itemCon.type == 0">满减券</p>
              <p class="list_name" v-if="itemCon.type == 1">任意抵扣券</p>
              <p class="list_price">{{itemCon.reduce_money}}元</p>
            </div>
            <div class="list_part list_part2 flex">
              <p class="list_from">{{itemCon.content}}</p>
              <p class="list_condition" v-if="itemCon.type == 0">消费满{{itemCon.limit_money}}元可使用</p>
              <p class="list_condition" v-if="itemCon.type == 1">可抵扣任意消费</p>
            </div>
            <div class="list_part list_part3 flex">
              <p class="list_begin">{{itemCon.addtime}}</p>
              <p class="list_end">有效期至：{{itemCon.validity}}</p>
            </div>
            <div class="list_left"></div>
            <div class="list_right"></div>
          </li>
        </ul>
        <ul>
          <li class="list" v-for="(itemCon,index) in tabContent0" v-show="1 == num" v-if="itemCon.status == 1">
            <div class="list_part list_part1 flex">
              <p class="list_name" v-if="itemCon.type == 0">满减券</p>
              <p class="list_name" v-if="itemCon.type == 1">任意抵扣券</p>
              <p class="list_price">{{itemCon.reduce_money}}元</p>
            </div>
            <div class="list_part list_part2 flex">
              <p class="list_from">{{itemCon.content}}</p>
              <p class="list_condition" v-if="itemCon.type == 0">消费满{{itemCon.limit_money}}元可使用</p>
              <p class="list_condition" v-if="itemCon.type == 1">可抵扣任意消费</p>
            </div>
            <div class="list_part list_part3 flex">
              <p class="list_begin">{{itemCon.addtime}}</p>
              <p class="list_end">有效期至：{{itemCon.validity}}</p>
            </div>
            <div class="list_left"></div>
            <div class="list_right"></div>
            <img class="list_img" src="/assets/img/used.png">
          </li>
        </ul>
        <ul>
          <li class="list" v-for="(itemCon,index) in tabContent0" v-show="2 == num" v-if="itemCon.status == 2">
            <div class="list_part list_part1 flex">
              <p class="list_name" v-if="itemCon.type == 0">满减券</p>
              <p class="list_name" v-if="itemCon.type == 1">任意抵扣券</p>
              <p class="list_price">{{itemCon.reduce_money}}元</p>
            </div>
            <div class="list_part list_part2 flex">
              <p class="list_from">{{itemCon.content}}</p>
              <p class="list_condition" v-if="itemCon.type == 0">消费满{{itemCon.limit_money}}元可使用</p>
              <p class="list_condition" v-if="itemCon.type == 1">可抵扣任意消费</p>
            </div>
            <div class="list_part list_part3 flex">
              <p class="list_begin">{{itemCon.addtime}}</p>
              <p class="list_end">有效期至：{{itemCon.validity}}</p>
            </div>
            <div class="list_left"></div>
            <div class="list_right"></div>
            <img class="list_img" src="/assets/img/over.png">
          </li>
        </ul>
      </div>
    </div>    
  </div>


</template>




<script>
import axios from 'axios'
import global from '../../../utils/global'
import store from '../../../utils/store'
export default {
  name: 'Order',
  data () {
    return {
      clientHeight:'',
      num: 0,
      tabs: ["未使用", "已使用", "已过期"],
      tabContent0: [
        {
          name: '满减券',
          price: '5',
          from: '邀请的好友消费一次',
          condition: '消费满20元可使用',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
        {
          name: '任意抵扣券',
          price: '5',
          from: '充值200元赠送',
          condition: '可抵扣任意消费',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
        {
          name: '满减券',
          price: '5',
          from: '邀请的好友消费一次',
          condition: '消费满20元可使用',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
        {
          name: '任意抵扣券',
          price: '5',
          from: '充值200元赠送',
          condition: '可抵扣任意消费',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
        {
          name: '满减券',
          price: '5',
          from: '邀请的好友消费一次',
          condition: '消费满20元可使用',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
        {
          name: '任意抵扣券',
          price: '5',
          from: '充值200元赠送',
          condition: '可抵扣任意消费',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
      ],
      tabContent1: [
        {
          name: '任意抵扣券',
          price: '5',
          from: '充值200元赠送',
          condition: '可抵扣任意消费',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
        {
          name: '满减券',
          price: '5',
          from: '邀请的好友消费一次',
          condition: '消费满20元可使用',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
        
      ],
      tabContent2: [
        {
          name: '满减券',
          price: '5',
          from: '邀请的好友消费一次',
          condition: '消费满20元可使用',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
        {
          name: '任意抵扣券',
          price: '5',
          from: '充值200元赠送',
          condition: '可抵扣任意消费',
          begin: '2018-07-05',
          end: '2018-07-15',
        },
      ],
    }
  },
  beforeCreate(){
    console.log(this.$route.params);
  },
  mounted(){
    this.clientHeight = `${document.documentElement.clientHeight}`
    window.onresize = function temp() {
      this.clientHeight = `${document.documentElement.clientHeight}`;
    };

    this.getInfo();

    this.$root.share();
  },
  watch: {
    clientHeight: function () {
      this.changeFixed(this.clientHeight)
    }
  },
  methods: {
    tab(index) {
        this.num = index;
    },
    changeFixed(clientHeight){
      // console.log(clientHeight);
      this.$refs.homePage.style.height = clientHeight+'px';
    },

    // 获取数据
    getInfo(){

      var that = this;

      axios.get(global.api.carCoupon.mycoupon,{
        params: {
          uuid: localStorage.getItem('carWashUuid'),
        }
      })

      .then(function(res){
        
        console.log("getInfo then");
        console.log(res);
        that.tabContent0 = res.data.data;
        // that.tabContent1 = res.data.data;
        // that.tabContent2 = res.data.data;

      })

      .catch(function(res){
        console.log("getInfo catch");
        console.log(res);
      })

    },
  },
}
</script>




<style scoped>
  .coupon_out{
    background-color: #EFEFEF;
  }
  .coupon{
    width: 100%;
    background-color: #EFEFEF;
  }
  .coupon_title{
    padding: 1rem 0;
    background-color: #fff;
  }
  .tabTit{
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    /*width: 100%;*/
    margin: 0rem 1rem;
    border: 1px solid #2ecc80;
    border-radius: 5px;
  }
  .tabTit li {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    height: 2rem;
    line-height: 2rem;
    color: #2ecc80;
  }
  .tabTit li:nth-child(2){
    border-left: 1px solid #2ecc80;
    border-right: 1px solid #2ecc80;
  }
  .tabTit .active{
    background-color: #2ecc80;
    color: #fff;
  }
  .list{
    width: 94%;
    margin: 0 3%;
    margin-top: 1rem;
    background-color: #fff;
    border-radius: 0.3rem;
    position: relative;
  }
  .list_part{
    justify-content: space-between;
    align-items: center;
    width: 90%;
    margin: 0 5%;
    padding: 0.5rem 0%;
    text-align: left;
  }
  .list_part1{}
  .list_part2{
    border-bottom: 1px dashed #B3B3B4;
    line-height: 1rem;
  }
  .list_part3{
    line-height: 1rem;
  }
  .list_name{
    font-size: 1.1rem;
    padding-left: 0.8rem;
  }
  .list_price{
    font-size: 1.6rem;
    color: #686868;
  }
  .list1 .list_price{
    color: #2ecc80;
  }
  .list_from{
    font-size: 0.8rem;
    padding-left: 0.8rem;
  }
  .list_condition{
    font-size: 0.8rem;
  }
  .list_begin{
    font-size: 0.8rem;
    padding-left: 0.8rem;
    color: #8A8A8A;
  }
  .list_end{
    font-size: 0.8rem;
  }
  .list_img{
    width: 3rem;
    height: 3rem;
    position: absolute;
    top: -0.6rem;
    left: 65%;
  }
  .list_left{
    width: 1rem;
    height: 1rem;
    position: absolute;
    background-color: #EFEFEF;
    border-radius: 50%;
    left: -0.5rem;
    bottom: 1.6rem;
  }
  .list_right{
    width: 1rem;
    height: 1rem;
    position: absolute;
    background-color: #EFEFEF;
    border-radius: 50%;
    right: -0.5rem;
    bottom: 1.6rem;
  }
</style>
<style>
  *{

  }
  ul,li,div,a,p,span{
    margin: 0;
    padding: 0;
  }
  li{
    list-style: none;
  }
  .flex{
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
  }
</style>